<?php

namespace Config;

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Filters\CSRF;
use CodeIgniter\Filters\DebugToolbar;
use CodeIgniter\Filters\Honeypot;
use App\Filters\AdminAuth;
use App\Filters\AdminNoAuth;
use App\Filters\AdminCheck;

class Filters extends BaseConfig
{
	/**
	 * 将一个简单的名称与一个或多个完整类的路径进行绑定关联，别名是强制性的
	 */
	public $aliases = [
		'csrf'     => CSRF::class,
		'toolbar'  => DebugToolbar::class,
		'honeypot' => Honeypot::class,
	    'adminAuth' => AdminAuth::class,
	    'adminNoAuth' => AdminNoAuth::class,
	    'adminCheck' => AdminCheck::class,
	];

	/**
	 * 定义应用程序中每个请求需要经过的过滤器
	 */
	public $globals = [
		'before' => [
		    'adminCheck',
			// 'honeypot',
		    'csrf' => ['except' => ['api/*', 'common/*']]
		],
		'after'  => [
			'toolbar',
			// 'honeypot',
		],
	];

	/**
	 * 将过滤器应用于请求的某些方法，只用于前置过滤，如['post' => ['csrf', 'throttle'],'get'  => ['csrf']]
	 */
	public $methods = [];

	/**
	 * 过滤器别名数组，每个别名可以定义指定 URI 的前置或后置过滤器:如，'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
	 */
	public $filters = [
	    // 'adminAuth' => ['before' => ['admin/*']],
	];
}
